<?php
namespace Home\Controller;
//忘记密码
use Common\Controller\HomebaseController;
use Common\Lib\RedisHandle;
use Common\Model\MembersModel;

class ForgetController extends HomebaseController {

    public function _initialize() {
        parent::_initialize();
        $this->feedback_model = M('feedback');
    }

    public function index(){
        $this->display();
    }

    public function dologin(){
        $mobile = I("post.mobile");
        $yzm = I("post.yzm");
        $password = I("post.password");

        $server_vcode = RedisHandle::getSMSVCode($mobile);
        if($server_vcode != $yzm){
            $this->ajaxReturn(array('code' => 400, 'message' => '验证码不正确'));
        }

        $member = M('members')->where(array('telephone' => $mobile))->find();
        if (!$member) {
            $this->ajaxReturn(array('code' => 404, 'message' => '该手机号未注册'));
        }
        $data = array(
            'password' => md5($password)
        );
        $memberModel = new MembersModel();
        $memberModel->modify($mobile, $data);
        $this->ajaxReturn(array('code' => 200, 'message' => '成功'));
    }
}


